home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / VS_804.ARJ / MISC.EXE / POPDICT.PRG < prev   
Text File  |  1991-11-15  |  2KB  |  92 lines

  1. * Filename......: PopDict.Prg
  2. *
  3. * Author........: Vernon E. Six, Jr.
  4. *
  5. * Last Update...: Fri  11-15-1991  10:57:18
  6. *
  7. * Notice........: Copyright (c) 1991 by Vernon E. Six, Jr.
  8. *                 All Rights Reserved World Wide
  9. *
  10. *                 All Forms Of Distribution Prohibited!
  11. *
  12. * Dialect.......: Clipper v5.0x
  13.  
  14.  
  15. #include "DBSTRUCT.CH"
  16.  
  17. FUNCTION PopDict(pc_DbfName)
  18. *****
  19. * Populates the _DICT*.* files for the specified DBF
  20. *****
  21. LOCAL a_Struct_ := {}
  22. LOCAL n_Cntr    := 0
  23.    
  24.    SET(_SET_EXCLUSIVE,.F.)
  25.  
  26.    VS_InitVern()
  27.    VS_NewScrn()
  28.  
  29.    IF PCOUNT() <> 1
  30.  
  31.       VS_Alert( {PADC("Proper Syntax: PopDict {DbfName}",50)}, {" OK "}, 3 )
  32.  
  33.       RETURN(NIL)
  34.  
  35.    ENDIF
  36.    
  37.    VS_OpenDict("_DICTHDR")
  38.    VS_OpenDict("_DICTFLD")
  39.  
  40.    IF VS_Use( pc_DbfName, .F., "TEMP", .T., .T. )
  41.  
  42.       a_Struct_ := TEMP->( dbStruct() )
  43.  
  44.       TEMP->( dbCloseArea() )
  45.  
  46.       *****
  47.       * Only add it if it doesn't exist
  48.       *****
  49.       IF .NOT. _DICTHDR->(dbSeek(UPPER(pc_DbfName)))
  50.  
  51.          IF _DICTHDR->( VS_AddRec() )
  52.  
  53.             _DICTHDR->DBF_NAME  := UPPER(pc_DbfName)
  54.  
  55.          ENDIF
  56.  
  57.       ENDIF
  58.  
  59.  
  60.       *****
  61.       * Delete the old structure (if it exists)
  62.       *****
  63.       DO WHILE _DICTFLD->( dbSeek(pc_DbfName,.F.) )
  64.  
  65.          IF _DICTFLD->( VS_DelRec() )
  66.             _DICTFLD->( dbUnlock()  )
  67.          ENDIF
  68.  
  69.       ENDDO
  70.  
  71.  
  72.       FOR n_Cntr = 1 TO LEN(a_Struct_)
  73.  
  74.          IF _DICTFLD->( VS_AddRec() )
  75.             _DICTFLD->DBF_NAME     := UPPER(pc_DbfName)
  76.             _DICTFLD->FIELD_NMBR   := STRZERO(n_Cntr*5,3)
  77.             _DICTFLD->FIELD_NAME   := a_Struct_[n_Cntr,DBS_NAME]
  78.             _DICTFLD->FIELD_TYPE   := a_Struct_[n_Cntr,DBS_TYPE]
  79.             _DICTFLD->FIELD_LEN    := a_Struct_[n_Cntr,DBS_LEN]
  80.             _DICTFLD->FIELD_DEC    := a_Struct_[n_Cntr,DBS_DEC]
  81.          ENDIF
  82.  
  83.       NEXT n_Cntr
  84.  
  85.    ENDIF
  86.  
  87.    dbCloseAll()
  88.  
  89. RETURN(NIL)
  90. *** EOF: PopDict() **********************************************************
  91.  
  92.